1 00:00:00,810 --> 00:00:02,810 Hello and welcome to this lecture. 2 00:00:02,850 --> 00:00:13,380 In this flick sure we will be creating the function for the app using JavaScript in this late show. 3 00:00:13,530 --> 00:00:23,040 We will be using several features in Javascript will be first we'll be creating variables. 4 00:00:23,550 --> 00:00:34,050 Variable is used to hold a single value we'll also be using a raise raise issues to hold or store multiple 5 00:00:34,050 --> 00:00:45,270 values as one or two using functions functions is what will front will use the functions to actually 6 00:00:45,300 --> 00:00:53,210 tell me what to do using the variables and the arrays. 7 00:00:53,340 --> 00:00:58,790 So the first time we are going to do here is create a variable. 8 00:00:58,860 --> 00:01:09,990 So this is our blank javascript file so to create a variable you type in the are lower case followed 9 00:01:09,990 --> 00:01:12,710 by the name you want to call the variable. 10 00:01:12,780 --> 00:01:14,670 In this case just give in. 11 00:01:14,720 --> 00:01:16,240 Then let her do it. 12 00:01:16,260 --> 00:01:22,560 You can call your variable whatever you like but there are set in mame's you can't use if you reference 13 00:01:22,560 --> 00:01:25,630 the javascript documentation. 14 00:01:25,650 --> 00:01:27,520 It will tell you. 15 00:01:28,280 --> 00:01:39,420 Then I have given it a value because to a new date this here is have function in javascript which tells 16 00:01:39,420 --> 00:01:46,320 you determine the function that will tell you the date set date function so the value the value of this 17 00:01:46,320 --> 00:01:47,840 variable will be. 18 00:01:47,840 --> 00:01:51,920 It was two new date whereby you see this back. 19 00:01:51,920 --> 00:01:53,070 This is you. 20 00:01:53,100 --> 00:01:57,160 He indicates that is a function. 21 00:01:57,170 --> 00:01:59,640 This every function was have this person. 22 00:01:59,640 --> 00:02:09,000 This is inside there is where you pass any values or arguments you want the function to use online to 23 00:02:09,180 --> 00:02:18,740 have created another variable poured week day and give it a value each or two new Arri and here has 24 00:02:18,750 --> 00:02:21,570 specified inside the parenthesis here. 25 00:02:21,600 --> 00:02:28,930 This specify the irey will be 7 so there will be 7 values stored inside that rate. 26 00:02:29,130 --> 00:02:33,490 So what I need to do now is specify those arrays. 27 00:02:34,200 --> 00:02:38,400 So I have specified the array from line 3 to 9. 28 00:02:38,400 --> 00:02:47,390 You can usually tell or identify an array with square brackets here where you have to see square brackets. 29 00:02:47,460 --> 00:02:51,980 You'd know that you are looking at an array here as specified. 30 00:02:51,990 --> 00:03:00,000 The value will be 7 4 and if you notice here the number and start from zero to six in that with an array 31 00:03:00,120 --> 00:03:06,280 the very first horray is given a number of zero and then the second value. 32 00:03:06,300 --> 00:03:15,540 So if I wanted to search or access the array with a value of zero bit excessive value called Sunday 33 00:03:16,190 --> 00:03:17,680 or named Sunday. 34 00:03:17,850 --> 00:03:21,440 Alright so the numbering starts with zero. 35 00:03:21,690 --> 00:03:30,900 So here it is half past 7 so there's zero counts as one counts as a value OK to make up that 7 so that 36 00:03:30,900 --> 00:03:34,460 would be 1 2 3 4 5 6 7. 37 00:03:34,740 --> 00:03:38,360 So I have now specifying the values of this race. 38 00:03:38,400 --> 00:03:43,410 Here I have created two more arrays. 39 00:03:43,470 --> 00:03:47,780 Sorry two more variables on line 11 and 12. 40 00:03:47,790 --> 00:03:48,920 The variable here. 41 00:03:48,950 --> 00:03:56,960 Call it date number two dates two and the value is equal to a new date line 12. 42 00:03:56,970 --> 00:04:01,900 This given a variable of weekday 2 to day value equals to an array. 43 00:04:02,090 --> 00:04:03,860 And I want it to have 7 as well. 44 00:04:03,870 --> 00:04:08,560 So I'm going to have to declare or specify the error here. 45 00:04:08,700 --> 00:04:11,220 Like I have done here. 46 00:04:12,030 --> 00:04:15,260 Okay so these are the arrays here. 47 00:04:15,290 --> 00:04:21,310 You can tell again this start from zero to 6 which makes up 7. 48 00:04:21,420 --> 00:04:22,590 So what this will be. 49 00:04:22,590 --> 00:04:30,810 This will be the actual text that will be displayed a long day of the week for example if did deal of 50 00:04:30,810 --> 00:04:38,140 the week is Sunday it would display tool chillax. 51 00:04:38,300 --> 00:04:46,290 OK I need to modify it at time too. 52 00:04:48,870 --> 00:04:54,750 Okay time to chillax. 53 00:04:55,750 --> 00:04:59,770 All right so that's what these are just a text that will be D. 54 00:04:59,840 --> 00:05:05,880 Played to correspond with each of the days of the week. 55 00:05:06,900 --> 00:05:15,570 I have created some more variables here like 21 22 24 and 25. 56 00:05:15,570 --> 00:05:18,910 So again you define a variable with the word. 57 00:05:19,110 --> 00:05:27,480 Ah lower case have given it in name of n and a value of set two was two week day this week day three 58 00:05:27,870 --> 00:05:31,680 and then there I have passed c d d d. 59 00:05:31,680 --> 00:05:36,950 Here is from this variable D here. 60 00:05:37,200 --> 00:05:40,160 Okay so up past did that value. 61 00:05:40,590 --> 00:05:45,030 So I posted that value inside this irey Dot get D. 62 00:05:45,270 --> 00:05:50,780 So this is a method of function that will get the day pass it into there. 63 00:05:50,800 --> 00:05:52,420 All right here again. 64 00:05:52,420 --> 00:05:53,330 Variable. 65 00:05:53,340 --> 00:06:01,300 Giving a name to the value will be day 2 and dates to do again. 66 00:06:01,320 --> 00:06:08,240 This is a name date two is the name of this variable here. 67 00:06:09,000 --> 00:06:10,090 Okay. 68 00:06:10,740 --> 00:06:24,460 And again we use this function to get the content of that tree and display it on line 24 to find another 69 00:06:24,480 --> 00:06:26,510 variable called display. 70 00:06:26,510 --> 00:06:27,840 We do. 71 00:06:28,200 --> 00:06:32,810 The value was to document to get element by D. 72 00:06:34,020 --> 00:06:35,550 This get element. 73 00:06:35,550 --> 00:06:41,750 But Heidi this is use our past sit this idea of week day. 74 00:06:42,110 --> 00:06:48,680 So if we look here we've got a night where our We've got the weekday e tool use. 75 00:06:48,680 --> 00:06:49,930 See that's the week. 76 00:06:49,940 --> 00:06:54,440 Then we use that week day this week. 77 00:06:54,440 --> 00:07:03,140 Day here is from our hastier mail document document or get element a D So if I pop up to the hastier 78 00:07:03,170 --> 00:07:08,010 mail here this is this is the idea is this looking for. 79 00:07:08,330 --> 00:07:12,690 So rather than display this text here to replace it. 80 00:07:12,710 --> 00:07:22,320 Take all that this I.D. and inject the code he replaces code with the javascript. 81 00:07:22,490 --> 00:07:24,050 Okay so that's what it means. 82 00:07:24,060 --> 00:07:25,790 It is replaced. 83 00:07:25,810 --> 00:07:26,500 What's this. 84 00:07:26,540 --> 00:07:35,480 This idea here by displaying the week day and this week here you will pick that from the irey again 85 00:07:35,480 --> 00:07:41,660 here this phrase here is variable phrase equal documental get elemen by phrase again. 86 00:07:42,020 --> 00:07:43,400 The phrase here is this. 87 00:07:43,400 --> 00:07:44,950 Here is tool. 88 00:07:44,990 --> 00:07:48,590 Replace the content here. 89 00:07:48,920 --> 00:07:52,860 What is in the erry I have specified. 90 00:07:53,230 --> 00:07:59,630 So so were you with the functions you have to get the variables defined first before you now create 91 00:07:59,660 --> 00:08:03,220 the function to use those variables. 92 00:08:03,440 --> 00:08:13,400 I have now created the function on line 29 to 34 so each time you grid of functionality was have apparently 93 00:08:13,400 --> 00:08:16,170 sees and also curly braces. 94 00:08:16,220 --> 00:08:23,000 This is the opening curly braces and this is the closing one right and in between the curly braces is 95 00:08:23,000 --> 00:08:29,570 what the function will do what you want the function to do so to define a function you type in the word 96 00:08:29,630 --> 00:08:34,220 function followed by the name of the function of this function. 97 00:08:34,220 --> 00:08:36,070 What day is it. 98 00:08:36,320 --> 00:08:38,690 So this is what I wanted a function to do. 99 00:08:38,690 --> 00:08:43,310 I want to display the dot in a text. 100 00:08:43,640 --> 00:08:51,180 So the weak display weak day which is this variable here it will display is variable dot in our text. 101 00:08:51,260 --> 00:08:53,790 Okay this in text is the. 102 00:08:53,830 --> 00:08:57,820 This year Miller's talking about an E tool set it. 103 00:08:57,920 --> 00:08:59,740 Replace that with this value. 104 00:08:59,810 --> 00:09:05,600 N the N here which is this variable here refers to a day week. 105 00:09:05,930 --> 00:09:11,350 Okay so it will get the tool get the week day and replace it weeks. 106 00:09:11,450 --> 00:09:14,560 The text from the hasty e-mail. 107 00:09:14,710 --> 00:09:15,000 Okay. 108 00:09:15,020 --> 00:09:17,520 That's what they mean again the same thing here. 109 00:09:17,560 --> 00:09:21,970 It will pick up this phrase here it will reply as is for this. 110 00:09:22,010 --> 00:09:29,270 In that text phrase with this end to hear the end to his day is a text that will go with the day of 111 00:09:29,270 --> 00:09:30,040 the week. 112 00:09:30,230 --> 00:09:32,470 Alright so the entire text me. 113 00:09:32,480 --> 00:09:35,320 Pop over to our email in our text. 114 00:09:35,320 --> 00:09:36,870 RIPLEY refers to these. 115 00:09:36,890 --> 00:09:38,750 This is known as in Tex. 116 00:09:38,870 --> 00:09:40,980 So what is in the US group. 117 00:09:41,010 --> 00:09:46,950 Replace this and inject its own code from the arrays into the. 118 00:09:47,000 --> 00:09:47,660 That's what it mean. 119 00:09:47,660 --> 00:09:51,180 This in our text it's referring to these are rights. 120 00:09:51,200 --> 00:10:00,290 So that's basically the javascript done so does make sure save it CLG file save or so. 121 00:10:00,320 --> 00:10:06,590 This is our document a refresh this is should not show the correct day of the week which is Saturday 122 00:10:06,590 --> 00:10:09,780 here in the UK is quite a refresh. 123 00:10:09,900 --> 00:10:13,980 So today is Saturday and time to party time. 124 00:10:14,050 --> 00:10:15,080 The party is. 125 00:10:15,080 --> 00:10:20,930 The text would have come with a food fight or pull my javits group file. 126 00:10:21,770 --> 00:10:31,650 Okay so today is Saturday which is day 6 and 6 here is gone. 127 00:10:31,670 --> 00:10:35,610 Time to party so this is a text that goes with it. 128 00:10:35,630 --> 00:10:39,070 So that's how this app works. 129 00:10:39,080 --> 00:10:39,850 That's it. 130 00:10:39,860 --> 00:10:47,290 We have finally finished our app that will determine what day of the week if it's. 131 00:10:47,570 --> 00:10:48,480 Thank you so much. 132 00:10:48,500 --> 00:10:51,680 This free to work on any web browser. 133 00:10:51,980 --> 00:10:52,650 Take care. 134 00:10:52,670 --> 00:10:53,790 All the best.